package wuuxiang.crm;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;

public class ElectronicQuanElement {
	public WebDriver driver;

	// 驱动
	public ElectronicQuanElement(WebDriver driver) {
		this.driver = driver;
		PageFactory.initElements(driver, this);

	}

	// 定位电子券元素
	@FindBy(name = "leftFrame")
	private WebElement zbk;

	@FindBy(xpath = "/html/body/div[2]/table/tbody/tr/td/div/h1[6]/a")
	private WebElement yxcl;

	@FindBy(id = "ticketKind")
	private WebElement qlx;

	@FindBy(name = "mainFrame")
	private WebElement ybk;

	@FindBy(name = "//*[contains(@src,'/shop/electroniccoupons/ElectroniccouponsAction.a')]")
	private WebElement ybk1;

	@FindBy(name = "add")
	private WebElement insert;

	@FindBy(id = "kindName")
	private WebElement kindName;

	@FindBy(id = "kindMoney")
	private WebElement kindMoney;

	@FindBy(id = "maxSendCount")
	private WebElement maxSendCount;

	@FindBy(id = "kindBeginDay")
	private WebElement kindBeginDay;

	@FindBy(id = "kindEndDay")
	private WebElement kindEndDay;

	@FindBy(id = "doSave")
	private WebElement qSave;

	@FindBy(xpath = "//*[@id='view_content']/table/tbody/tr[2]/td[4]")
	private WebElement dx;

	@FindBy(id = "edit")
	private WebElement edit;

	@FindBy(id = "kindCode")
	private WebElement number;

	@FindBy(id = "doSearch")
	private WebElement search;

	@FindBy(id = "doDel")
	private WebElement delete;

	// 新增按钮
	public void findLeft() {
		yxcl.click();
		qlx.click();
	}

	public void findyxcl() {
		yxcl.click();
	}

	public void findRight() {
		insert.click();

	}

	// 新增信息
	public void insertpage(String a, String b, String c) {
		kindName.clear();
		kindName.sendKeys(a);
		Log.getLogger(ElectronicQuanElement.class).info("新增电子券：" + "[" + a + "]");
		kindMoney.clear();
		kindMoney.sendKeys(b);
		maxSendCount.clear();
		maxSendCount.sendKeys(c);
		kindBeginDay.click();

	}

	// 保存
	public void qsave() {
		qSave.click();
		 Log.getLogger(ElectronicQuanElement.class).info("新增电子券成功");
	}

	// 修改
	public void d(String a) {
		dx.click();
		edit.click();
		kindName.clear();
		kindName.sendKeys(a);
		qSave.click();
	}

	// 查询
	public void e(String a) {
		number.clear();
		number.sendKeys(a);
		search.click();
	}

	// 删除
	public void f() {
		dx.click();
		delete.click();
	}

}
